package com.yelink.metrics.cases.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yelink.metrics.cases.config.MyModelType;
import com.yelink.metrics.core.constant.annotations.MetricsColumn;
import com.yelink.metrics.core.constant.annotations.MetricsInfo;
import com.yelink.metrics.core.constant.annotations.MetricsView;
import com.yelink.metrics.core.constant.enums.FieldDefine;
import com.yelink.metrics.core.constant.enums.TimeDimension;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;

/**
 * 示例模板
 * <p>{@link MetricsInfo} 指标表相关信息</p>
 * <p>{@link MetricsView} 视图相关信息</p>
 * @author idea
 */
@Data
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor
@MetricsInfo(comment = "案例视图", modelEnum = MyModelType.class, modelCode = "metricsSdkTarget")
@MetricsView(sql =
        "select \n" +
        "\tdemo as v_demo, \n" +
        "\trecord_time as v_record_time, \n" +
        "\tia_val as v_ia_val, \n" +
        "\tdescription as v_description \n" +
        "from dfs_metrics.metrics_demo_daily")
@TableName(value = "metrics_v_demo", schema = "dfs_metrics")
public class ViewEntity{

    /**
     * {@link MetricsColumn} 指标字段相关信息： 字段定义为维度或时间维度时需要明确的标注出来； 当为时间维度时，需要标记
     */
    @MetricsColumn(comment = "指标中文名", remark = "更多说明?", filedDefine = FieldDefine.DIMENSION)
    @TableField(value = "v_demo")
    private String vDemo;

    /**
     * {@link MetricsColumn} 指标字段相关信息：当为时间维度时，需要标记 timeEnum
     */
    @MetricsColumn(comment = "记录日期", filedDefine = FieldDefine.TIME_DIMENSION, timeEnum = TimeDimension.DAY)
    @TableField(value = "v_record_time")
    private Date vRecordTime;


    @MetricsColumn(comment = "电压值", remark = "指标值的计算公式", filedDefine = FieldDefine.TARGET)
    @TableField(value = "v_ia_val")
    private Double vIaVal;

    @MetricsColumn(comment = "说明", remark = "这是一个说明书", filedDefine = FieldDefine.ATTACHMENT)
    @TableField(value = "v_description")
    private String vDescription;


}
